
<template>
  <div id="app" v-bind:style="appDivStyle">
    <div class="context" ref="context">
      <div class="queryBox" ref="queryBox">
        <el-form :model="formQueryCondition" ref="form" size="mini">
          <!--查询条件-->
          <el-row>
            <el-col :span="5">
              <!-- 演员编号 -->
              <el-form-item :label="$t('Actor.queryLabel.code')" :label-width="queryformLabelWidth">
                <el-input
                  v-model.trim="formQueryCondition.actorCode.val"
                  class="queryItemStyle"
                  clearable
                  :placeholder="$t('Actor.queryLabel.placeholderCode')"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5" :offset="1">
              <!-- 演员姓名 -->
              <el-form-item :label="$t('Actor.queryLabel.name')" :label-width="queryformLabelWidth">
                <el-input
                  v-model.trim="formQueryCondition.actorName.val"
                  class="queryItemStyle"
                  clearable
                  :placeholder="$t('Actor.queryLabel.placeholderName')"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5" :offset="1">
              <!-- 姓名简拼 -->
              <el-form-item :label="$t('Actor.queryLabel.pName')" :label-width="queryformLabelWidth">
                <el-input
                  v-model.trim="formQueryCondition.actorPy.val"
                  class="queryItemStyle"
                  clearable
                  :placeholder="$t('Actor.queryLabel.placeholderPName')"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5" :offset="1">
              <!-- 演员别名 -->
              <el-form-item :label="$t('Actor.queryLabel.byName')" :label-width="queryformLabelWidth">
                <el-input
                  v-model.trim="formQueryCondition.actorAlName.val"
                  class="queryItemStyle"
                  clearable
                  :placeholder="$t('Actor.queryLabel.placeholderByName')"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="5">
              <!-- 性别 -->
              <el-form-item :label="$t('actorQueryLabel.role.sex')" :label-width="queryformLabelWidth">
                <el-select
                  v-model="formQueryCondition.sex.val"
                  class="queryItemStyle"
                >
                  <el-option :label="$t('label.all')" value></el-option>
                  <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText"
                                    v-for="drug in gender"></el-option>
                  <!-- <el-option :label="$t('label.man')" value="Man"></el-option>
                  <el-option :label="$t('label.women')" value="Women"></el-option> -->
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="5" :offset="1">
              <!-- 英文名 -->
              <el-form-item :label="$t('Actor.queryLabel.enName')" :label-width="queryformLabelWidth">
                <el-input
                  v-model.trim="formQueryCondition.actorEnName.val"
                  class="queryItemStyle"
                  clearable
                  :placeholder="$t('Actor.queryLabel.placeholderEnName')"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5" :offset="1">
              <!-- 审核状态 -->
              <el-form-item
                :label="$t('Actor.queryLabel.approvalStatus')"
                :label-width="queryformLabelWidth"
              >
                <el-select
                  v-model="formQueryCondition.approvalStatus.val"
                  class="queryItemStyle"
                >
                  <el-option :label="$t('label.all')" value></el-option>
                <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText"
                                    v-for="drug in ApprovalStatus"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="5" :offset="1">
                <!-- 状态 -->
              <el-form-item :label="$t('AssetsProviderManage.queryLabel.status')"  :label-width="queryformLabelWidth">
                    <el-select v-model="formQueryCondition.isEnable.val" class="queryItemStyle" >
                        <el-option :label="$t('label.all')" value=""></el-option>
                        <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText"
                                v-for="drug in enables"></el-option>
                        <!-- <el-option :label="$t('label.available')" value="Available"></el-option>
                        <el-option :label="$t('label.invalid')" value="Invalid"></el-option> -->
                    </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="5">
            <el-form-item :label="$t('playBillManage.queryLabel.sendtoState')" disabled :label-width="queryformLabelWidth">
                <el-select v-model="formQueryCondition.sendtoState.val" class="queryItemStyle">
                    <el-option :label="$t('label.all')" value=""></el-option>
                    <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText"
                        v-for="drug in sendStateGroup"></el-option>
                </el-select>
            </el-form-item>
            </el-col>
          </el-row>
          <!--事件按钮-->
          <el-row>
            <el-col :span="24">
              <div style="text-align:right">
                <!--返回-->
                <el-form-item v-if="isNeedGoBack">
                  <el-button type="primary" @click="back" icon="el-icon-back">{{ $t('Actor.btnText.backBtnText') }}</el-button>
                </el-form-item>
                <!-- <el-form-item>
                  <el-button type="primary" @click="onGetPhoto">{{ $t('Actor.btnText.getPhotoBtnText') }}</el-button>
                </el-form-item> -->
                <el-form-item>
                  <el-button v-permission="{menuCode: menuCode,resourceCode: 'saveActorBtnText'}" type="primary" @click="onNew('saveActorBtnText')">{{ $t('btnText.newBtnText') }}</el-button>
                <!-- </el-form-item> -->
                <!-- <el-form-item> -->
                  <el-button v-permission="{menuCode: menuCode,resourceCode: 'resetActorBtnText'}" type="primary" @click="onReset('form')">{{ $t('btnText.resetBtnText') }}</el-button>
                <!-- </el-form-item> -->
                <!-- <el-form-item> -->
                  <el-button v-permission="{menuCode: menuCode,resourceCode: 'exportActorBtnText'}" type="primary" @click="onExport('exportActorBtnText')" icon="el-icon-upload2" :loading="loading" >{{ $t('btnText.exportBtnText') }}</el-button>
                <!-- </el-form-item> -->
                <!-- <el-form-item> -->
                  <el-button v-permission="{menuCode: menuCode,resourceCode: 'ImportBtnText'}" type="primary" @click="onImport('ImportBtnText')" icon="el-icon-download" >{{ $t('btnText.importBtnText') }}</el-button>
                <!-- </el-form-item> -->
                <!--导入模板下载-->
                <!-- <el-form-item> -->
                    <el-button v-permission="{menuCode:menuCode,resourceCode:'downloadTemplate'}" type="primary" @click="downloadTemplate('downloadTemplate')" icon="el-icon-download" :loading="loading">{{ $t('playManage.btnText.downloadTemplate') }}</el-button>
                <!-- </el-form-item> -->
                <!-- <el-form-item> -->
                  <el-button v-permission="{menuCode: menuCode,resourceCode: 'queryActorBtnText'}" type="primary" @click="onQuery('queryActorBtnText')" icon="el-icon-search" :loading="loading" >{{ $t('btnText.queryBtnText') }}</el-button>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div class="dataBox" ref="dataBox">
        <!--数据表格-->
        <transition enter-active-class="animated zoomIn" leave-active-class="animated rotateOut">
          <el-table
            v-if="isInit"
            ref="singleTable"
            :data="tableData"
            :height="tableHeight"
            @sort-change="sortChange"
            v-loading="loading"
            size="mini"
            style="width: 100%;"
            stripe="stripe"
            border="border"
          >
            <el-table-column
              type="index"
              width="50"
              fixed="left"
              :label="$t('actorTable.xh')"
              align="center"
            ></el-table-column>
            <el-table-column :label="$t('table.op')" fixed="left" min-width="360">
              <template slot-scope="scope">
                <el-button v-permission="{menuCode: menuCode,resourceCode: 'editActorBtnText'}" size="gv" icon="el-icon-edit" :loading="loading" @click="edit(scope.$index, scope.row,'editActorBtnText')" >{{ $t('btnText.editBtnText') }}</el-button>
                <el-button v-permission="{menuCode: menuCode,resourceCode: 'detailsActorBtnText'}" size="gv" icon="el-icon-search" :loading="loading" @click="onDetails(scope.$index, scope.row,'detailsActorBtnText')" >{{ $t('btnText.detailsBtnText') }}</el-button>
                <!-- <el-button size="gv" icon="el-icon-delete"
                                          type="danger" :loading="loading" @click="deleteRow(scope.$index, scope.row)"
                >{{ $t('btnText.deleteBtnText') }}</el-button>-->
                <el-button v-permission="{menuCode: menuCode,resourceCode: 'auditingActorBtnText'}" size="gv" :disabled="scope.row.approvalStatus !='PendingReview'" icon="el-icon-edit" :loading="loading" @click="onAuditing(scope.$index, scope.row,'auditingActorBtnText')" >{{ $t('btnText.auditingBtnText') }}</el-button>

                <!-- 下发 -->
                <el-button size="gv" icon="el-icon-delete"
                    v-permission="{menuCode: menuCode, resourceCode: 'sendBtnText'}"
                    type="danger" :loading="loading" @click="onSend(scope.$index, scope.row,'sendBtnText')"
                    :disabled="scope.row.sendtoState!='StayDown' || scope.row.isEnable !='Available' || scope.row.approvalStatus !='ExaminationPassed'" >{{ $t('btnText.sendBtnText') }}</el-button>
                <!-- 恢复 -->
                <el-button size="gv" icon="el-icon-delete" v-show="scope.row.isEnable==='Invalid'" v-permission="{menuCode: menuCode,resourceCode: 'recoveryBtnText'}" type="danger" :loading="loading" @click="revertLogoffRow(scope.$index, scope.row,'recoveryBtnText')" >{{ $t('btnText.recoveryBtnText') }}</el-button>
                <!-- 删除 -->
                <el-button v-permission="{menuCode: menuCode,resourceCode: 'delBtnText'}" size="gv" icon="el-icon-delete" v-show="scope.row.isEnable=='Invalid'" type="danger" :loading="loading" @click="deleteRow(scope.$index, scope.row,'delete')" >{{ $t('btnText.deleteBtnText') }}</el-button>
                <!-- 注销 -->
                <el-button v-permission="{menuCode: menuCode,resourceCode: 'passActorBtnText'}" size="gv" icon="el-icon-delete" v-show="scope.row.isEnable=='Available'" type="danger" :loading="loading" @click="logoffRow(scope.$index, scope.row,'passActorBtnText')" >{{ $t('btnText.logoffBtnText') }}</el-button>
                <!-- <el-button v-permission="{menuCode: menuCode,resourceCode: 'passActorBtnText'}" size="gv" icon="el-icon-delete" type="danger" :loading="loading" @click="logoffRow(scope.$index, scope.row)" >{{ $t('btnText.logoffBtnText') }}</el-button> -->
                <!-- 重资产管理跳转过来显示的按钮为 -->
                <!-- <el-button v-permission="{menuCode: menuCode,resourceCode: 'editBtnText'}" size="gv" icon="el-icon-edit" :loading="loading" @click="onEdit(scope.$index, scope.row)" >{{ $t('btnText.editBtnText') }}</el-button>
                <el-button v-permission="{menuCode: menuCode,resourceCode: 'detailsBtnText'}" size="gv" icon="el-icon-search" :loading="loading" @click="onDetails(scope.$index, scope.row)" >{{ $t('btnText.detailsBtnText') }}</el-button>
                <el-button v-permission="{menuCode: menuCode,resourceCode: 'auditingBtnText'}" size="gv" icon="el-icon-edit" :loading="loading" @click="onAuditing(scope.$index, scope.row)" >{{ $t('btnText.auditingBtnText') }}</el-button>
                <el-button v-permission="{menuCode: menuCode,resourceCode: 'passBtnText'}" size="gv" icon="el-icon-delete" type="danger" :loading="loading" @click="logoffRow(scope.$index, scope.row)" >{{ $t('btnText.logoffBtnText') }}</el-button> -->
              </template>
            </el-table-column>
            <el-table-column
              prop="actorCode"
              min-width="150"
              :label="$t('Actor.table.code')"
              sortable="custom"
              sort-by="actorCode"
            ></el-table-column>
            <el-table-column
              prop="actorName"
              min-width="110"
              :label="$t('Actor.table.name')"
              sortable="custom"
              sort-by="actorName"
            ></el-table-column>
            <el-table-column
              prop="actorPy"
              min-width="130"
              :label="$t('Actor.table.pName')"
              sortable="custom"
              sort-by="actorPy"
            ></el-table-column>
            <el-table-column
              prop="actorAlName"
              min-width="130"
              :label="$t('Actor.table.byName')"
              sortable="custom"
              sort-by="actorAlName"
            ></el-table-column>
            <el-table-column
              prop="approvalStatusName"
              min-width="130"
              :label="$t('Actor.table.approvalStatus')"
              sortable="custom"
              sort-by="approvalStatus"
            ></el-table-column>
            <el-table-column
              prop="sex"
              min-width="110"
              :label="$t('Actor.table.sex')"
              sortable="custom"
              sort-by="sex"
            ></el-table-column>
            <!-- <el-table-column
              prop="nationality"
              min-width="110"
              :label="$t('actorTable.nationality')"
              sortable="custom"
              sort-by="nationality"
            ></el-table-column> -->
            <el-table-column
              prop="actorEnName"
              min-width="110"
              :label="$t('Actor.table.enName')"
              sortable="custom"
              sort-by="actorEnName"
            ></el-table-column>
            <!--下发状态-->
                    <el-table-column prop="sendtoStateName" min-width="110"
                                        :label="$t('ParentAssetIssuance.table.ParentAssetIssuance.status')" sortable="custom" sort-by="sendtoState">
                    </el-table-column>
          </el-table>
        </transition>
      </div>
    </div>
    <div class="pageBox">
      <el-pagination
        @size-change="sizeChange"
        @current-change="currentPageChange"
        :current-page="pager.curPage"
        :page-sizes="pager.sizes"
        :page-size="pager.curSize"
        :background="true"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pager.total"
      ></el-pagination>
    </div>

    <!--编辑对话框-->
    <transition enter-active-class="animated rotateIn" leave-active-class="animated rotateOut">
      <el-dialog :title="$t('label.dialogTitle')" :visible.sync="isEditForm" top="5vh" :close-on-click-modal="false">
        <el-form
          :inline="true"
          :model="editForm"
          ref="editForm"
          size="mini"
          :label-position="editFormPosition"
          status-icon="status-icon"
          :rules="editRules"
        >
          <!--基本信息-->
          <el-row>
            <el-col class="datacol titlecol" :span="titleSpan">{{ $t('Actor.editLabel.baseInfoTitle') }}</el-col>
          </el-row>
          <el-input v-model.trim="editForm.keyId"  v-show="false"></el-input>
          <!-- 演员编号 -->
          <!-- <el-form-item
            :label="$t('Actor.editLabel.code')"
            :label-width="editformLabelWidth"
            prop="actorCode"
          >
            <el-input v-model.trim="editForm.actorCode" maxlength="20"></el-input>
          </el-form-item> -->
          <!-- 演员姓名 -->
          <el-form-item
            :label="$t('Actor.editLabel.name')"
            :label-width="editformLabelWidth"
            prop="actorName"
          >
            <el-input v-model.trim="editForm.actorName" maxlength="20"></el-input>
          </el-form-item>
          <!-- 姓名简拼 -->
          <el-form-item
            :label="$t('Actor.editLabel.pName')"
            :label-width="editformLabelWidth"
            prop="actorPy"
          >
            <el-input v-model.trim="editForm.actorPy" maxlength="50"></el-input>
          </el-form-item>

          <!-- 性别 -->
          <el-form-item
            :label="$t('Actor.editLabel.sex')"
            :label-width="editformLabelWidth"
            prop="sex"
          >
            <el-select v-model="editForm.sex" :placeholder="$t('Actor.editLabel.pleaseChoose')" style="width:180PX;">
              <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText"
                                v-for="drug in gender"></el-option>
              <!-- <el-option :label="$t('label.man')" value="Man"></el-option>
              <el-option :label="$t('label.women')" value="Women"></el-option> -->
            </el-select>
          </el-form-item>
           <!-- 演员别名 -->
          <el-form-item
            :label="$t('Actor.editLabel.byName')"
            :label-width="editformLabelWidth"
            prop="actorAlName"
          >
            <el-input v-model.trim="editForm.actorAlName" maxlength="50"></el-input>
          </el-form-item>
           <!--职业-->
          <!-- <el-form-item
            :label="$t('Actor.editLabel.profession')"
            :label-width="editformLabelWidth"
            prop="profession"
          >
            <el-select v-model="editForm.profession" style="width:180px;">
              <el-option :label="$t('label.actor')" value="Actor"></el-option>
              <el-option :label="$t('label.screenwriter')" value="Screenwriter"></el-option>
              <el-option :label="$t('label.director')" value="Director"></el-option>
              <el-option :label="$t('label.host')" value="Host"></el-option>
              <el-option :label="$t('label.fieldService')" value="FieldService"></el-option>
            </el-select>
          </el-form-item> -->
          <!-- 英文名 -->
          <el-form-item
            :label="$t('Actor.editLabel.enName')"
            :label-width="editformLabelWidth"
            prop="actorEnName"
          >
            <el-input v-model.trim="editForm.actorEnName" maxlength="50"></el-input>
          </el-form-item>

          <!--头像-->
          <el-row>
            <el-form-item
              :label="$t('editLabel.actor.headPortrait')"
              :label-width="editformLabelWidth"
              prop="actorLogo"
            >
            <!-- <el-upload size="tiny" ref="upload1" action="#" :data="editForm" accept=".png,.jpg,.jpeg"
                        :multiple="false" :on-preview="handlePreview" :on-remove="handleRemove" :on-error = "error" :on-success = "success" :file-list="fileList1" :auto-upload="false"
                        :limit="1" :on-exceed="handleExceed" :before-upload="beforeUpload1">
                        <el-button :loading="loading" round slot="trigger" size="mini" type="primary">选取文件</el-button>
                        <div slot="tip" class="el-upload__tip">只能上传600*800的jpg/png文件</div>
                    </el-upload> -->
            <!-- <el-upload
              class="avatar-uploader"
              size="tiny" ref="upload1" action="#" :data="editForm" accept=".png,.jpg,.jpeg"
              list-type="picture"
              :multiple="false" :on-preview="handlePreview" :before-upload="beforeUpload1" :on-remove="handleRemove" :on-error ="error" :on-success ="success" :file-list="fileList1" :auto-upload="false"
               :limit="1" :on-exceed="handleExceed" >
              <img v-if="imageUrl" :src="imageUrl" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload> -->
            <!-- :show-file-list="false" v-show="false" -->
            <el-input v-model.trim="editForm.actorLogo" v-show="false"  width="120" ></el-input>
            	<el-upload
                class="avatar-uploader"
                :show-file-list="false"
                :action="action"
                accept=".png,.jpg,.jpeg"
                :data="{site:'public',type:'actor_logo'}"
                :on-success="handleAvatarSuccess"
                :before-upload="beforeAvatarUpload">
                <img v-if="imageUrl" :src="imageUrl" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
            </el-row>
            <el-row>
          <!--背景图片-->
            <el-form-item
              :label="$t('editLabel.actor.backgroundPicture')"
              :label-width="editformLabelWidth"
              prop="actorBgPic"
            >
            <!--  :auto-upload="false"   -->
              <!-- <el-upload size="tiny" ref="upload2" action="#" :data="editForm" accept=".png,.jpg,.jpeg"
              list-type="picture"
              :multiple="false"
              :auto-upload="false"
                         :on-preview="handlePreview" :on-remove="handleRemove" :on-error ="error" :on-success ="success" :file-list="fileList2"
                        :limit="1" :on-exceed="handleExceed" :before-upload="beforeUpload2">
                        <el-button :loading="loading" round slot="trigger" size="mini" type="primary">选取文件</el-button>
                        <div slot="tip" class="el-upload__tip">只能上传800*600的jpg/png文件</div>
                    </el-upload> -->
                     <el-input v-model.trim="editForm.actorBgPic" v-show="false"  width="120" ></el-input>
            	<el-upload
                class="avatar-uploader"
                :show-file-list="false"
                :action="action"
                :data="{site:'public',type:'actor_bg_pic'}"
                accept=".png,.jpg,.jpeg"
                :on-success="handleAvatarSuccess2"
                :before-upload="beforeAvatarUpload2">
                <img v-if="imageUrl2" :src="imageUrl2" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
          </el-row>
          <!-- 作品信息 -->
          <el-form-item
            :label="$t('Actor.editLabel.worksInfo')"
            :label-width="editformLabelWidth"
            prop="actorInformation"
          >
            <el-input v-model.trim="editForm.actorInformation" type="textarea" :rows="2" maxlength="500" :placeholder="$t('Actor.editLabel.pleaseEnterContent')" style="width:490px;"></el-input>
          </el-form-item>
          <!--简介-->
          <el-row>
            <el-form-item
              :label="$t('Actor.editLabel.summary')"
              :label-width="editformLabelWidth"
              prop="actorDesc"
            >
              <el-input v-model.trim="editForm.actorDesc" type="textarea" :rows="2" maxlength="500" :placeholder="$t('Actor.editLabel.pleaseEnterContent')" style="width:490px;"></el-input>
            </el-form-item>
          </el-row>

          <!--隐私信息-->
          <!-- <el-row>
            <el-col class="datacol titlecol" :span="titleSpan">{{ $t('隐私信息') }}</el-col>
          </el-row>
          <el-form-item
            :label="$t('editLabel.actor.bornDate')"
            :label-width="editformLabelWidth"
            prop="bornDate"
          >
            <el-date-picker v-model="editForm.bornDate" class="queryItemStyle" placeholder="选择日期"></el-date-picker>
          </el-form-item>
          <el-form-item
            :label="$t('editLabel.actor.constellation')"
            :label-width="editformLabelWidth"
            prop="constellation"
          >
            <el-select v-model="editForm.constellation" style="width:180px;">
              <el-option :label="$t('白羊座')" value="1"></el-option>
              <el-option :label="$t('水平座')" value="2"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            :label="$t('editLabel.actor.hight')"
            :label-width="editformLabelWidth"
            prop="hight"
          >
            <el-input v-model.trim="editForm.hight" maxlength="20"></el-input>
          </el-form-item>
          <el-form-item
            :label="$t('editLabel.actor.weight')"
            :label-width="editformLabelWidth"
            prop="weight"
          >
            <el-input v-model.trim="editForm.weight" maxlength="50"></el-input>
          </el-form-item>
          <el-form-item
            :label="$t('editLabel.actor.bloodType')"
            :label-width="editformLabelWidth"
            prop="bloodType"
          >
            <el-select v-model="editForm.bloodType" style="width:180px;">
              <el-option :label="$t('A')" value="1"></el-option>
              <el-option :label="$t('AB')" value="2"></el-option>
              <el-option :label="$t('B')" value="1"></el-option>
              <el-option :label="$t('O')" value="2"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            :label="$t('editLabel.actor.graduateInstitutions')"
            :label-width="editformLabelWidth"
            prop="graduateInstitutions"
          >
            <el-input v-model.trim="editForm.graduateInstitutions" maxlength="20"></el-input>
          </el-form-item>
          <el-form-item
            :label="$t('editLabel.actor.nationality')"
            :label-width="editformLabelWidth"
            prop="nationality"
          >
            <el-input v-model.trim="editForm.nationality" maxlength="50"></el-input>
          </el-form-item>
          <el-form-item
            :label="$t('editLabel.actor.homePlace')"
            :label-width="editformLabelWidth"
            prop="homePlace"
          >
            <el-input v-model.trim="editForm.homePlace" maxlength="20"></el-input>
          </el-form-item>
          <el-form-item
            :label="$t('editLabel.actor.microblog')"
            :label-width="editformLabelWidth"
            prop="microblog"
          >
            <el-input v-model.trim="editForm.microblog" maxlength="50"></el-input>
          </el-form-item> -->


          <!--作品信息-->
          <!-- <el-row>
            <el-col class="datacol titlecol" :span="titleSpan">{{ $t('作品信息') }}</el-col>
          </el-row>
          <el-form-item
            :label="$t('editLabel.actor.musicWorks')"
            :label-width="editformLabelWidth"
            prop="musicWorks"
          >
            <el-input v-model="editForm.musicWorks" maxlength="100"></el-input>
          </el-form-item>
          <el-form-item
            :label="$t('editLabel.actor.score')"
            :label-width="editformLabelWidth"
            prop="score"
          >
            <el-input v-model.trim="editForm.score" maxlength="50"></el-input>
          </el-form-item>
          <el-form-item
            :label="$t('editLabel.actor.heat')"
            :label-width="editformLabelWidth"
            prop="heat"
          >
            <el-input v-model.trim="editForm.heat" maxlength="50"></el-input>
          </el-form-item> -->


        </el-form>
        <div slot="footer">
          <el-button
            size="mini"
            @click="isEditForm = false"
            :loading="loading"
          >{{ $t('btnText.cancelBtnText') }}</el-button>
          <el-button
            size="mini"
            type="primary"
            @click="submitForm('editForm',currentResCode)"
            :loading="loading"
          >{{ $t('btnText.saveBtnText') }}</el-button>
        </div>
      </el-dialog>
    </transition>

    <el-dialog :title="$t('btnText.importBtnText')" width="400px" :visible.sync="dlgUploadVisible" :close-on-click-modal="false">
      <upload-file
        v-bind:uploadUrl="uploadCourseMaterialUrl"
        v-bind:acceptFileType="'.xlsx'"
        v-bind:uploadParams="uploadCourseMaterialParams"
        v-bind:fileList="fileList"
        v-bind:autoUpload="false"
        v-bind:fileLimit="1"
        v-bind:selectName="$t('Actor.editLabel.selectFile')"
        v-bind:uploadBtn="$t('Actor.editLabel.submission')"
        v-bind:fileTypeText="'xlsx'"
        v-bind:submitSuccess="submitUploadSuccess"
        v-bind:menuCode="menuCode"
      ></upload-file>
    </el-dialog>

    <!--详情对话框-->
    <transition enter-active-class="animated rotateIn" leave-active-class="animated rotateOut">
      <el-dialog :title="$t('Actor.editLabel.details')" :visible.sync="isShowEditForm2" top="5vh" :close-on-click-modal="false">
        <el-form
          :inline="true"
          :model="editForm"
          ref="editForm"
          size="mini"
          :label-position="editFormPosition"
          status-icon="status-icon"
          :rules="editRules"
        >
          <!--基本信息-->
          <el-row class="datarow">
            <el-col class="datacol titlecol" :span="titleSpan">{{ $t('Actor.editLabel.essentialInformation') }}</el-col>
          </el-row>
          <!-- 头像 -->
          <el-row class="datarow">
             <el-col class="labcol" :span="labelSpan">{{ $t('editLabel.actor.headPortrait') + ":" }}</el-col>
             <el-col class="datacol" :span="dataSpan"><img v-bind:src="editForm.actorLogo" height="100" width="70"></el-col>
             <el-col class="labcol" :span="labelSpan">{{ $t('editLabel.actor.backgroundPicture') + ":" }}</el-col>
             <el-col class="datacol" :span="dataSpan"><img v-bind:src="editForm.actorBgPic" height="100" width="70"></el-col>
          </el-row>
          <el-row class="datarow bgrow">
            <el-col class="labcol" :span="labelSpan">{{ $t('editLabel.actor.name') + ":" }}</el-col>
            <el-col class="datacol" :span="21">{{ editForm.actorName }}</el-col>
          </el-row>
          <el-row class="datarow">
            <el-col class="labcol" :span="labelSpan">{{ $t('editLabel.actor.byName') + ":" }}</el-col>
            <el-col class="datacol" :span="dataSpan">{{ editForm.actorAlName }}</el-col>
            <el-col class="labcol" :span="labelSpan">{{ $t('editLabel.actor.sex') + ":" }}</el-col>
            <el-col class="datacol" :span="dataSpan">{{ editForm.sex}}</el-col>
          </el-row>
          <el-row class="datarow bgrow">
            <el-col class="labcol" :span="labelSpan">{{ $t('editLabel.actor.enName') + ":" }}</el-col>
            <el-col class="datacol" :span="dataSpan">{{ editForm.actorEnName }}</el-col>
            <el-col class="labcol" :span="labelSpan">{{ $t('editLabel.actor.pName') + ":" }}</el-col>
            <el-col class="datacol" :span="dataSpan">{{ editForm.actorPy }}</el-col>
          </el-row>

          <!--背景图片-->
          <!-- <el-row class="datarow">
            <el-col
              class="labcol"
              :span="labelSpan"
            >{{ $t('editLabel.actor.backgroundPicture') + ":" }}</el-col>
            <el-col class="datacol" :span="dataSpan">{{ editForm.actorBgPic }}</el-col>
          </el-row> -->
          <!--作品信息-->
          <el-row class="datarow">
            <el-col class="labcol" :span="labelSpan">{{ $t('editLabel.actor.actorInformation') + ":" }}</el-col>
            <el-col
              class="datacol"
              :span="21"
              type="textarea"
            >{{ editForm.actorInformation }}</el-col>
          </el-row>
          <!--简介-->
          <el-row class="datarow bgrow">
            <el-col class="labcol" :span="labelSpan">{{ $t('editLabel.actor.synopsis') + ":" }}</el-col>
            <el-col class="datacol" :span="21" type="textarea">{{ editForm.actorDesc }}</el-col>
          </el-row>

        </el-form>
        <div slot="footer">
          <el-button
            size="mini"
            @click="isShowEditForm2 = false"
            :loading="loading"
          >{{ $t('btnText.cancelBtnText') }}</el-button>
          <el-button
            size="mini"
            type="primary"
            @click="isShowEditForm2 = false"
            :loading="loading"
          >{{ $t('btnText.saveBtnText') }}</el-button>
        </div>
      </el-dialog>
    </transition>

    <!--审核对话框-->
    <el-dialog :title="$t('assetsAudit.auditing')" :visible.sync="isShowAuditForm" top="5vh" width="60%" :close-on-click-modal="false">
      <el-form :model="auditForm" ref="auditForm" size="mini" :label-position="editFormPosition" status-icon="status-icon"
        :rules="auditRules" >
        <el-form-item :label="$t('assetsAudit.auditSuggestion')" :label-width="editformLabelWidth" prop="reviewDesc">
          <el-input v-model.trim="auditForm.reviewDesc" type="textarea" :rows="2" :placeholder="$t('Actor.editLabel.pleaseEnterContent')" ></el-input>
        </el-form-item>
        <el-form-item :label-width="editformLabelWidth">
          <el-button size="mini" type="primary" @click="auditSuccess(currentResCode)" :loading="loading" >{{$t('assetsAudit.pass')}}</el-button>
          <el-button size="mini" type="primary" @click="submitFormForReject('auditForm',currentResCode)" :loading="loading" >{{$t('assetsAudit.reject')}}</el-button>
          <el-button size="mini" @click="isShowAuditForm = false" :loading="loading" >{{ $t('btnText.cancelBtnText') }}</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import comBaseVue from "../../baseViewModel";

export default {
  mixins: [comBaseVue],
  name: "Actor",
  props: {
    isNeedGoBack: Boolean,
    curRootAssets: Object,
    menuCode: String
  },
  components: {
    'upload-file': () => import('../common/UploadFile')
  },
  data() {
    return {
      imageUrl: "",
      imageUrl2: "",
      // 是否正在提交中
      loading: false,
      //真正的实体类名称
      modelName: "com.ispr.iptv.entity.media.MediaActor",
      // 是否正在提交中
      loading: false,
      /////////////////文件导入///////////////////
      uploadCourseMaterialUrl: '/api/import/upload',
      uploadCourseMaterialParams: null,
      fileList: [],
      isInit: false,
      isNonEditable: false,
      tableData: [],
      gender: [],
      sendStateGroup:[],
      ApprovalStatus: [],
      isShowAuditForm: false,
      //编辑布局
      //标题
      titleSpan: 24,
      labelSpan: 3,
      dataSpan: 9,
      appDivStyle: {
        height: this.$store.getters.appHeight
      },
      // 查询条件
      formQueryCondition: {
        actorCode: {
          key: "actorCode",
          op: "LIKE", // 操作符
          val: "" // 查询的值
        },
        actorName: {
          key: "actorName",
          op: "LIKE", // 操作符
          val: "" // 查询的值
        },
        actorPy: {
          key: "actorPy",
          op: "LIKE", // 操作符
          val: "" // 查询的值
        },
        actorAlName: {
          key: "actorAlName",
          op: "LIKE", // 操作符
          val: "" // 查询的值
        },
        sex: {
          key: "sex",
          op: "=", // 操作符
          val: "" // 查询的值
        },
        actorEnName: {
          key: "actorEnName",
          op: "LIKE", // 操作符
          val: "" // 查询的值
        },
        isEnable: {
          key: "isEnable",
          op: "=", // 操作符
          val: "Available"
        },
        approvalStatus: {
          key: "approvalStatus",
          op: "=", // 操作符
          val: ""
        },
        sendtoState:{
          key:'sendtoState',
          op: '=',
          val:''
        },
      },
      queryformLabelWidth: "75px",
      editformLabelWidth: "120px",
      editFormPosition: "right",
      //下发
      sendForm: {
        siteList: [], //下发到的站点
        sendType: ""
      },
      // 分页对象
      pager: {
        curPage: 1,
        sizes: [20, 30, 50, 100, 200, 400],
        curSize: 20,
        total: 0
      },
      // 排序对象
      sort: {
        key: "keyId",
        dir: "Desc"
      },
      enables: [],
      // 是否显示编辑面板
      isEditForm: false,
      isShowEditForm2: false,
      // 当前编辑面板执行的命令
      curCommand: "SaveNew",
      canEditCode: false,

      dlgUploadVisible: false,
      // 编辑面板绑定的对象
      editForm: {
        keyId: 0,
        version: 0,
        actorCode: "",
        actorName: "",
        actorPy: "",
        actorAlName: "",
        sex: "",
        actorEnName: "",
        actorLogo: "",
        actorBgPic: "",
        actorInformation: "",
        actorDesc: "",
        sendtoState: "StayDown"
      },
      editRules: {
        actorCode: [
          {
            required: true,
            message: this.$i18n.t("Actor.rules.code"),
            trigger: "blur"
          }
        ],
        actorName: [
          {
            required: true,
            message: this.$i18n.t("Actor.rules.name"),
            trigger: "blur"
          }
        ],
        sex: [
          {
            required: true,
            message: this.$i18n.t("Actor.rules.sex"),
            trigger: "change"
          }
        ],
        actorPy: [
          {
            required: true,
            message: this.$i18n.t("Actor.rules.janeSpell"),
            trigger: "blur"
          }
        ],
        actorLogo:[
          {
            required: true,
            message: this.$i18n.t("Actor.rules.headPortrait"),
            trigger: "change"
          }
        ]
        // actorLogo: [{required: true,message: this.$i18n.t("Actor.rules.headPortrait"),trigger: "blur"}],
      },
      //审核面板绑定属性
      auditForm: {
        keyId: "",
        version: 0,
        assetVersion: "",
        reviewDataType: "",
        isEnable: "",
        approvalStatus: "",
        reviewDesc: ""
      },
      // 审核面板的验证规则
      auditRules: {
        reviewDesc: [
          {
            required: true,
            message: this.$i18n.t("assetsAudit.rules.auditSuggestion"),
            trigger: "blur"
          }
        ]
      },

      //////////////////////////////////上传文件/////////////////////
      // uploadUrl: '/api/channel/channelSave', //请求地址
      uploadUrl: "/api/mediaActor/mediaActorSave", //请求地址
      fileList1: [], //文件集合
      fileList2: [], //文件集合
      file1: null,
      file2: null
    };
  },
  methods: {
    // 新增
    onNew: function(rescode) {
      this.currentResCode = rescode && rescode !== "" ? rescode : "";
      // this.uploadUrl = '/api/mediaActor/mediaActorSave';
      this.isEditForm = true;
      if (this.$refs["editForm"]) {
        this.$refs["editForm"].resetFields();
      }
      this.editForm.keyId = "";
      this.editForm.version = "";
      this.editForm.actorCode = "";
      this.editForm.actorName = "";
      this.editForm.actorPy = "";
      this.editForm.actorAlName = "";
      this.editForm.sex = "";
      this.editForm.actorEnName = "";
      this.editForm.actorLogo = "";
      this.editForm.actorBgPic = "";
      this.editForm.actorInformation = "";
      this.editForm.actorDesc = "";
      this.imageUrl = "";
      this.imageUrl2 = "";
      this.editForm.isEnable = "Available";
      this.editForm.approvalStatus = "PendingReview";
      this.editForm.sendtoState = "StayDown";
      this.fileList1 = [];
      this.fileList2 = [];
      this.curCommand = "PerformerProc";
      // this.canEditCode = false;
      this.isNonEditable = true;
    },
    //编辑面板提交后调用，设置唯一性验证条件
    setEditFormCheck: function setEditFormCheck() {
      // if (this.curCommand == "PerformerProc") {
      //   this.editFormCheck = [
      //     {
      //       key: "actorCode",
      //       op: "=", // 操作符
      //       val: this.editForm.actorCode // 查询的值
      //     },
      //     {
      //       key: "isEnable",
      //       op: "=", // 操作符
      //       val: "Available"
      //     }
      //   ];
      // } else if (this.curCommand == "PartialUpdateProc") {
      //   this.editFormCheck = [
      //     {
      //       key: "actorCode",
      //       op: "=", // 操作符
      //       val: this.editForm.actorCode // 查询的值
      //     },
      //     {
      //       key: "isEnable",
      //       op: "=", // 操作符
      //       val: "Available"
      //     },
      //     {
      //       key: "keyId",
      //       op: "<>", // 操作符
      //       val: this.editForm.keyId
      //     }
      //   ];
      // }
    },
    // 查询按钮
    onQuery: function(resCode) {
      this.currentResCode = resCode && resCode !== "" ? resCode : "";
      this.pager.curPage = 1;
      this.queryTable();
    },
    // 重置
    onReset: function() {
      if (this.$refs["form"]) {
        this.$refs["form"].resetFields();
      }
      this.formQueryCondition.actorCode.val = "";
      this.formQueryCondition.actorName.val = "";
      this.formQueryCondition.actorPy.val = "";
      this.formQueryCondition.actorAlName.val = "";
      this.formQueryCondition.sex.val = "";
      this.formQueryCondition.actorEnName.val = "";
      this.formQueryCondition.approvalStatus.val = "PendingReview";
      this.formQueryCondition.isEnable.val = "Available";
    },
    // 注销按钮
        logoffRow: function(index, row, rescode) {
            this.currentResCode = (rescode && rescode!=='') ? rescode : '';
            var _this = this;
            this.$confirm(this.$i18n.t("message.confirmlogoffMessage"),
                this.$i18n.t("message.confirmTitle"), {
                confirmButtonText: this.$i18n.t("message.yes"),
                cancelButtonText: this.$i18n.t("message.cancel"),
                type: "warning",
                callback: function (action, instance) {
                    if (action == "confirm") {
                        var commandBody = {  "keyId": row.keyId, "version": row.version, isEnable: "Invalid", sendtoState:"StayDown" };
                        _this.loading = true;
                        _this.procCommand("PassProc",//PartialUpdateProc
                                _this.modelName,
                                "N",
                                commandBody,
                                null,
                                _this.submitFormCallback);
                    }

                }
            });
        },
        // 恢复注销按钮
        revertLogoffRow: function(index, row, rescode) {
            this.currentResCode = (rescode && rescode!=='') ? rescode : '';
            var _this = this;
            this.$confirm(this.$i18n.t("message.confirmNormalMessage"),
                this.$i18n.t("message.confirmTitle"), {
                confirmButtonText: this.$i18n.t("message.yes"),
                cancelButtonText: this.$i18n.t("message.cancel"),
                type: "warning",
                callback: function (action, instance) {
                    if (action == "confirm") {
                        var commandBody = {  "keyId": row.keyId, "version": row.version, isEnable: "Available", sendtoState:"StayDown" };
                        _this.loading = true;
                        _this.procCommand("RecoveryProc",//PartialUpdateProc
                                _this.modelName,
                                "N",
                                commandBody,
                                null,
                                _this.submitFormCallback);
                    }

                }
            });
        },

    // 导出按钮
    onExport: function(rescode) {
      this.currentResCode = rescode && rescode !== "" ? rescode : "";
      let param = {
        className: "com.ispr.iptv.entity.media.MediaActor",
        opKey: "Export",
        params: this.queryObjToArray(this.formQueryCondition) ,

        sort: [{ col: "keyId", order: "desc" }],
        fileName: "演员管理"
      };
      let fileName = "演员管理" + ".xlsx";
      this.downloadByIdOrName(
        this,
        "/file/export",
        "param",
        JSON.stringify(param),
        fileName
      );
    },
    // //导入按钮
    // onImport: function() {
    //   this.$message({
    //     message: this.$i18n.t("操作成功"),
    //     type: "success"
    //   });
    // },
    //审核按钮
    // onAuditing: function() {
    //   this.$message({
    //             message: this.$i18n.t("操作成功" ),
    //             type: 'success'
    //             });
    // },
    onAuditing: function(index, row, rescode) {
      this.currentResCode = rescode && rescode !== "" ? rescode : "";
      if (this.$refs["auditForm"]) {
          this.$refs["auditForm"].resetFields();
        }
      // this.isAuditInfoForm = true;
      this.auditForm.assetVersion = row.version;
      this.auditForm.reviewDesc = "";
      (this.auditForm.reviewDataId = row.keyId),
        (this.auditForm.reviewDataType = "ACTOR"),
        (this.auditForm.isEnable = "Available"),
        // this.auditRules.auditSuggestion.message = "";
        (this.isShowAuditForm = true);
    },
    //审核通过
    auditSuccess: function(rescode) {
      this.currentResCode = rescode && rescode !== "" ? rescode : "";
      (this.auditForm.approvalStatus = "ExaminationPassed"),
        //this.auditForm.opType= "ExaminationPassed",
        (this.loading = true);
      this.procCommand(
        "MediaAuditProc",
        "com.ispr.iptv.entity.media.MediaActor",
        "Default",
        {
          keyId: this.auditForm.reviewDataId,
          version: this.auditForm.assetVersion,
          approvalStatus: this.auditForm.approvalStatus,
          reviewHisEntity: this.auditForm
        },
        null,
        this.commonCallback
      );
    },
    //审核未通过
    submitFormForReject: function(formName, rescode) {
      this.currentResCode = rescode && rescode !== "" ? rescode : "";
      var _this = this;
      (this.auditForm.approvalStatus = "TheAuditFailed"),
        this.$refs[formName].validate(function(valid) {
          if (valid) {
            _this.loading = true;
            _this.procCommand(
              "MediaAuditProc",
              "com.ispr.iptv.entity.media.MediaActor",
              "Default",
              {
                keyId: _this.auditForm.reviewDataId,
                version: _this.auditForm.assetVersion,
                approvalStatus: _this.auditForm.approvalStatus,
                reviewHisEntity: _this.auditForm
              },
              null,
              _this.commonCallback
            );
          } else {
            return false;
          }
        });
    },
    commonCallback: function(isSuccess, json) {
      this.loading = false;
      this.isShowAuditForm = false;
      if (isSuccess) {
         if (this.$refs["editForm"]) {
          this.$refs["editForm"].resetFields();
        }
        this.$message({
          message: this.$i18n.t("message.successTip"), //resource.message.successTip,
          type: "success"
        });
        this.queryTable();
      } else {
        this.$message({
          message: json.msg,
          type: "warning"
        });
      }
    },
    //详情按钮
    onDetails: function(index, row, rescode) {
      this.currentResCode = rescode && rescode !== "" ? rescode : "";
      //dataAccess.queryDomainModelByKeyID(this, modelName, "Query", row.keyID, true, this.$options.methods.editCallback);
      this.queryModelByKeyID(
        this.modelName,
        row.keyId,
        "Query",
        this.onDetailsCallback
      );
    },

    onDetailsCallback: function(isSuccess, json) {
      if (isSuccess) {
        this.isShowEditForm2 = true;
        if (this.$refs["editForm"]) {
          this.$refs["editForm"].resetFields();
        }
        this.editForm.keyId = json.keyId;
        this.editForm.actorCode = json.actorCode;
        this.editForm.actorName = json.actorName;
        this.editForm.actorPy = json.actorPy;
        this.editForm.actorAlName = json.actorAlName;
        this.editForm.sex = json.sex;
        this.editForm.actorEnName = json.actorEnName;
        this.editForm.actorInformation = json.actorInformation;
        this.editForm.actorDesc = json.actorDesc;
        this.editForm.actorLogo = json.actorLogo;
        this.editForm.actorBgPic = json.actorBgPic;
        this.editForm.approvalStatus = "PendingReview";
        this.canEditCode = false;
      } else {
        this.$message({
          message: json.msg,
          type: "warning"
        });
      }
    },
    // // 提交编辑面板数据
    // submitForm2: function submitForm2(formName) {
    //   var _this = this;

    //   this.$refs[formName].validate(function(valid) {
    //     if (valid) {
    //       _this.loading = true;
    //       _this.procCommand(
    //         _this.curCommand,
    //         _this.modelName,
    //         "Default",
    //         _this.editForm,
    //         _this.submitForm2Callback
    //       );
    //     } else {
    //       return false;
    //     }
    //   });
    // },
    // // 执行命令后的回调函数
    // submitForm2Callback: function submitForm2Callback(isSuccess, json) {
    //   this.loading = false;
    //   if (isSuccess) {
    //     this.isShowEditForm2 = false;
    //     this.$message({
    //       message: this.$i18n.t("message.successTip"), //resource.message.successTip,
    //       type: "success"
    //     });
    //     this.queryTable();
    //   } else {
    //     this.$message({
    //       message: this.$i18n.t("errorCode." + json.reason),
    //       type: "warning"
    //     });
    //   }
    // },
    //提取图片按钮
    onGetPhoto: function() {
      this.$message({
        message: this.$i18n.t("操作成功"),
        type: "success"
      });
    },
    // 分页容量变化
    sizeChange: function(val) {
      this.pager.curPage = 1;
      this.pager.curSize = val;
      this.queryTable();
    },
    // 分页按钮
    currentPageChange: function(val) {
      this.pager.curPage = val;
      this.queryTable();
    },
    // 生成网格的序号
    indexCreate: function(index) {
      return (this.pager.curPage - 1) * this.pager.curSize + (index + 1);
    },
    // 排序回调函数
    sortChange: function(sortObj) {
      console.log(sortObj);
      this.pager.curPage = 1;
      this.sort.key = sortObj.column.sortBy;
      if (sortObj.order == "ascending") {
        this.sort.dir = "asc";
      } else {
        this.sort.dir = "desc";
      }
      this.queryTable();
    },

    // 编辑按钮单击事件
    edit: function(index, row, rescode) {
      this.currentResCode = rescode && rescode !== "" ? rescode : "";
      this.imageUrl = "";
      this.imageUrl2 = "";
      //dataAccess.queryDomainModelByKeyID(this, modelName, "Query", row.keyID, true, this.$options.methods.editCallback);
      this.queryModelByKeyID(
        this.modelName,
        row.keyId,
        "byId",
        this.editCallback
      );
    },
    // 编辑按钮回调事件
    editCallback: function(isSuccess, json) {

      if (isSuccess) {
        // this.imageUrl = "";
        // this.imageUrl2 = "";
        this.uploadUrl = "/api/mediaActor/mediaActorUpdate";
        this.curCommand = "PartialUpdateProc";
        this.isEditForm = true;
        if (this.$refs["editForm"]) {
          this.$refs["editForm"].resetFields();
        }
        // this.editForm = json;
        // this.canEditCode = true;

        this.editForm.keyId = json.keyId; //ID
        this.editForm.actorCode = json.actorCode; //演员编号
        this.editForm.actorName = json.actorName; //演员姓名
        this.editForm.actorPy = json.actorPy; //演员简称
        //演员别名
        this.editForm.actorAlName = "";
        if(json.actorAlName !== ""){
            this.editForm.actorAlName = json.actorAlName;
        }
        //英文名
        this.editForm.actorEnName = "";
        if(json.actorEnName !== ""){
            this.editForm.actorEnName = json.actorEnName;
        }
        //头像
        this.editForm.actorLogo = "";
        if(json.actorLogo !== ""){
          this.editForm.actorLogo = json.actorLogo;
          this.imageUrl = json.actorLogo;
        }
        //背景图片
        this.editForm.actorBgPic ="";
        this.imageUrl2 = "";
        if(json.actorBgPic !== ""){
          this.editForm.actorBgPic = json.actorBgPic;
          this.imageUrl2 = json.actorBgPic;
        }
        //作品信息
        this.editForm.actorInformation = "";
        if(json.actorInformation !== ""){
          this.editForm.actorInformation = json.actorInformation;
        }
        //简介
        this.editForm.actorDesc = "";
        if(json.actorDesc !== ""){
          this.editForm.actorDesc = json.actorDesc;
        }

        this.editForm.sex = json.sex;

        // this.editForm.actorLogo = "1234";
        this.editForm.approvalStatus = "PendingReview";
        this.editForm.sendtoState = "StayDown";
        this.editForm.version = json.version;
        // this.fileList1 = [{name:json.actorLogo,uid:1,percentage:0,raw:{uid:1},status:"ready"}];
        // this.fileList2 = [{name:json.actorBgPic,uid:1,percentage:0,raw:{uid:1},status:"ready"}];
        this.isNonEditable = true;
      } else {
        this.$message({
          message: json.msg,
          type: "warning"
        });
      }
    },
       // 提交编辑面板数据
        submitForm: function submitForm(formName, rescode){

            this.currentResCode = (rescode && rescode!=='') ? rescode : '';
            var _this = this;
            this.setEditFormCheck();

            this.$refs[formName].validate(function (valid) {
                if (valid) {
                    _this.loading = true;
                    _this.procCommand(_this.curCommand,
                    _this.modelName,
                    "Default",
                    _this.editForm,
                    _this.editFormCheck,
                    _this.submitFormCallback);
                } else {
                    return false;
                }
            });
        },
    //单个下发
    onSend: function(index, row, rescode) {
      var _this = this;
      this.currentResCode = rescode && rescode !== "" ? rescode : "";
      this.sendForm.sendType = "single";
      this.singleSend = {};
      let data = {
        "keyId": row.keyId,
        "version":row.version,
        resType: "ACTOR"
      };
      let dataList = []; //最终传给后台的总数据
      dataList.push(data);
      this.$confirm(
        this.$i18n.t("message.confirmSendMessage"),
        this.$i18n.t("message.confirmTitle"),
        {
          confirmButtonText: this.$i18n.t("message.yes"),
          cancelButtonText: this.$i18n.t("message.cancel"),
          type: "warning",
          callback: function(action, instance) {
            if (action == "confirm") {
              _this.loading = true;
              _this.procCommand(
                "MediaSendToProc",
                _this.modelName,
                "Default",
                {
                  dataList: dataList
                },
                null,
                _this.submitFormCallback
              );
            }
          }
        }
      );
    },

    // 删除按钮
    // deleteRow: function(index, row) {
    //   var _this = this;
    //   this.$confirm(
    //     this.$i18n.t("message.confirmDelMessage"),
    //     this.$i18n.t("message.confirmTitle"),
    //     {
    //       confirmButtonText: this.$i18n.t("message.yes"),
    //       cancelButtonText: this.$i18n.t("message.cancel"),
    //       type: "warning",
    //       callback: function(action, instance) {
    //         if (action == "confirm") {
    //           console.log(_this);
    //           console.log(row);
    //           var commandBody = {
    //             data: [{ keyID: row.keyID, ver: row.version }],
    //             count: 1
    //           };
    //           _this.loading = true;
    //           _this.procCommand(
    //             "DelProc",
    //             _this.modelName,
    //             "N",
    //             commandBody,
    //             _this.submitFormCallback
    //           );
    //         }
    //       }
    //     }
    //   );
    // },
    /////下载导入模板
    downloadTemplate: function downloadTemplate (rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
      this.downloadByIdOrName(this, '/import/downtemplate', 'fileName', '演员管理导入模板.xlsx', '演员管理导入模板.xlsx');
    },
    /////////////////////////////////// 演员管理导入 ///////////////////////////////////////////
    //导入按钮
    onImport: function(rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
       let _this = this;
      // this.$alert(this.$t('Actor.message.import'), this.$t('Actor.message.tips'), {
      //   confirmButtonText: this.$t('Actor.message.determine'),
      //   callback: action => {
          // if (action === 'confirm') {
            // 初始化错误文件下载id
            _this.errorTaskId = null;
            // 清空文件列表
            _this.fileList = [];
            _this.dlgUploadVisible = true;
            // this.uploadPhorderUrl = this.baseUrl+'/import/upload';
            _this.uploadCourseMaterialParams = {'className': _this.modelName};
          // }
      //   }
      // });
    },
    submitUploadSuccess: function submitUploadSuccess (response, file, fileList) {

      if (response.code === 'SUCCESS') {
        if (response.data.status === '0') {
          this.dlgUploadVisible = false;
          this.$message.success('导入成功');
          this.fileList = []; // 清空上传文件列表
          // 刷新表格数据
          this.onQuery();
          return false;
        }
        if (response.data.status === '3') {
          let _this = this;
          this.$alert('导入失败，是否下载失败原因文件?', '提示', {
            confirmButtonText: '确定',
            callback: function callback (action) {
              if (action === 'confirm') {
                _this.downloadByIdOrName(_this, '/import/downerr', 'taskId', response.data.taskId, response.data.errFileName);
              } else {
                _this.$message({
                  type: 'info',
                  message: '已取消'
                });
              }
            }
          });
          this.fileList = []; // 清空上传文件列表
          this.dlgUploadVisible = false;
        }
      } else {
        this.$message.error(response.msg);
      }
    },


    // 查询网格数据
    queryTable: function() {
      this.loading = true;
      this.queryModel(
        this.modelName,
        "Query",
        this.formQueryCondition,
        this.pager,
        this.sort,
        this.setTableData
      );
    },
    // 查询网格数据成功后的回调
    // setTableData: function(isSuccess, json) {
    //   this.loading = false;
    //   try {
    //     if (isSuccess) {
    //       this.pager.total = json.recordCount;
    //       this.tableData = [];
    //       for (var i = 0; i < json.queryResult.length; i++) {
    //         this.tableData.push(json.queryResult[i]);
    //       }
    //     } else {
    //       this.$message.error(this.$i18n.t("errorCode." + json.reason));
    //     }
    //   } catch (e) {
    //     alert(e);
    //   }
    // },
    // 提交编辑面板数据
    submitEditForm: function(formName) {
      var _this = this;

      this.$refs[formName].validate(function(valid) {
        if (valid) {
          _this.loading = true;
          _this.procCommand(
            _this.curCommand,
            _this.modelName,
            "Default",
            _this.editForm,
            _this.submitFormCallback
          );
        } else {
          return false;
        }
      });
    },
    // 执行命令后的回调函数
    submitFormCallback: function(isSuccess, json) {

      this.loading = false;
      if (isSuccess) {
        this.isEditForm = false;
        this.$message({
          message: this.$i18n.t("message.successTip"), //resource.message.successTip,
          type: "success"
        });
        this.queryTable();
      } else {
        this.$message({
          message: json.msg,
          type: "warning"
        });
      }
    },

    //回退事件
    back: function(isSuccess, json) {
      //this.$router.go(-1);//后退
      this.$parent.setCurrentComponent("goBack", null);
    },
    // 为性别下拉框赋值
    findGender: function() {
      this.findByTypeCode("10003", this.setGender);
    },
    // 查询性别下拉框数据成功后的回调
    setGender: function(isSuccess, json) {
      try {
        if (isSuccess) {
          this.gender = [];
          for (var i = 0; i < json.data.length; i++) {
            this.gender.push(json.data[i]);
          }
        } else {
          this.$message.error(
            json.msg
          );
        }
      } catch (e) {
        alert(e);
      }
    },
    // 为资产状态下拉框赋值
    findApprovalStatus: function() {
      this.findByTypeCode("10007", this.setApprovalStatus);
    },
    // 查询资产状态下拉框数据成功后的回调
    setApprovalStatus: function(isSuccess, json) {
      try {
        if (isSuccess) {

          this.ApprovalStatus = [];
          for (var i = 0; i < json.data.length; i++) {
            if(json.data[i].valueCode !== "Discard"){
              this.ApprovalStatus.push(json.data[i]);
            }
          }
        } else {
          this.$message.error(
            json.msg
          );
        }
      } catch (e) {
        alert(e);
      }
    },
    initTable: function() {
      this.tableHeight =
        this.$refs.context.offsetHeight - this.$refs.queryBox.offsetHeight;
      this.isInit = true;
    },

    /////////////////////////////文件上传//////////////////////////////////////////////
    //表单提交
    submitUpload: function submitUpload(rescode) {
      this.currentResCode = rescode && rescode !== "" ? rescode : "";
      // alert("上传");
      var B = false;
      this.$refs["editForm"].validate(function(valid) {
        if (!valid) {
          B = true;
        }
      }); //数据表单验证
      if (B) {
        return false;
      }
      //文件表单验证
      if (
        !this.$refs.upload1.uploadFiles.length ||
        this.$refs.upload1.uploadFiles.length <= 0
      ) {
        this.$message.warning("您未选择上传文件");
        return false;
      }
      if (
        !this.$refs.upload2.uploadFiles.length ||
        this.$refs.upload2.uploadFiles.length <= 0
      ) {
        this.$message.warning("您未选择上传文件");
        return false;
      }
      this.$refs.upload1.submit();
      this.$refs.upload2.submit();
      window.setTimeout(() => {
        let formData = new FormData();
        // formData.append('data', this.editForm);
        formData.append("keyId", this.editForm.keyId);
        formData.append("version", this.editForm.version);
        formData.append("actorCode", this.editForm.actorCode);
        formData.append("actorName", this.editForm.actorName);
        formData.append("actorPy", this.editForm.actorPy);
        formData.append("actorAlName", this.editForm.actorAlName);
        formData.append("sex", this.editForm.sex);
        formData.append("actorEnName", this.editForm.actorEnName);
        formData.append("actorInformation", this.editForm.actorInformation);
        formData.append("actorDesc", this.editForm.actorDesc);
        formData.append("approvalStatus", this.editForm.approvalStatus);
        formData.append("isEnable", this.editForm.isEnable);

        // formData.append('file1', this.$refs.upload.uploadFiles[0]);
        // formData.append('file2', this.$refs.upload2.uploadFiles[0]);
        formData.append("file1", this.file1);
        formData.append("file2", this.file2);
        let headersObj = {
          "Content-Type": "application/json",
          Authorization: "Bearer " + this.getUserInfo().tokenCode,
          "X-AOHO-UserId": this.getUserInfo().keyID
        };
        if (this.isExistResourceCode(this)) {
          headersObj["X-AOHO-Resource"] =
            this.menuCode + "," + this.currentResCode;
        }
        this.axios
          .post(
            this.uploadUrl,
            formData,
            { headers: headersObj }
            //  {
            //   headers: {
            //     'Content-Type': 'multipart/form-data'
            //   }
            // }
          )
          .then(res => {
            console.log("上传成功333===》", res);
            if (res.data.code === "SUCCESS") {
              this.$message.success("操作成功！");
              this.isEditForm = false;
              this.onQuery();
            } else {
              this.$message.error(res.data.msg);
            }
          })
          .catch(function(error) {
            console.log(error);
          });
      }, 500);
    },
    // getFileTest: function (event) {
    //   this.file2 = event.target.files[0];
    //   console.log('this.file2==>', this.file2);
    // },
    // getFileTest2: function (event) {
    //   this.file1 = event.target.files[0];
    //   console.log('this.file111111==>', this.file1);
    // },
    //上传时的钩子
    beforeUpload1: function(file) {
      this.file1 = file;
      console.log("this.file11111111111121==>", this.file1);
      // 取消上传
      //this.$refs.upload1.abort(this.$refs.upload1.uploadFiles[0]);
      return false;
    },
    //上传时的钩子
    beforeUpload2: function(file, fileList) {
      this.file2 = file;
      console.log("this.file2222222222222212==>", this.file2);
      //this.$refs.upload2.abort(this.$refs.upload2.uploadFiles[0]);
      return false;
    },
    // 移除文件
    handleRemove: function handleRemove(file, fileList) {
      //this.$message.success('移除成功！');
    },
    // 点击文件列表中已上传的文件时的钩子
    handlePreview: function handlePreview(file) {},
    // 文件超出个数限制时的钩子
    handleExceed: function handleExceed(files, fileList) {
      this.$message("上传文件数量超过限制");
    },
    //文件上传失败时的钩子
    error: function error() {
      this.$message.error("上传失败！");
    },
    //文件上传成功时的钩子
    success: function success(response, file, fileList) {
      if (response.code === "SUCCESS") {
        this.$message.success("上传成功！");
        this.isShowEditForm = false;
        this.onQuery();
      } else {
        this.$message.error(response.msg);
      }
    },// 为下发状态下拉框赋值
  findSendState: function() {
      this.findByTypeCode("10011",this.setSendStates)
  },
  // 查询状态下拉框数据成功后的回调
  setSendStates: function(isSuccess,json) {
      try{
          if (isSuccess) {
              this.sendStateGroup = [];
              for (var i = 0; i < json.data.length; i++) {
                  this.sendStateGroup.push(json.data[i]);
              }
          }
          else {
              this.$message.error(json.msg);
          }
      }
      catch(e){
          alert(e);
      }
  },
    // 为状态下拉框赋值
    findEnables: function() {
        this.findByTypeCode("10001",this.setEnables)
    },
    // 查询状态下拉框数据成功后的回调
    setEnables: function(isSuccess,json) {
        try{
            if (isSuccess) {
                this.enables = [];
                for (var i = 0; i < json.data.length; i++) {
                    this.enables.push(json.data[i]);
                }
            }
            else {
                this.$message.error(json.msg);
            }
        }
        catch(e){
            alert(e);
        }
    },
    /////////////////////////////////////////上传结束///////////////////////////////////////////////////////
    handleAvatarSuccess(res, file) {
      // this.imageUrl = URL.createObjectURL(file.raw);
      // alert(res.data);
      // alert(URL.createObjectURL(file.raw));
      this.imageUrl = res.data;
      this.editForm.actorLogo = res.data;
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传头像图片只能是 JPG 格式!");
      }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    },
    handleAvatarSuccess2(res, file) {
      // this.imageUrl = URL.createObjectURL(file.raw);
      // alert(res.data);
      // alert(URL.createObjectURL(file.raw));
      this.imageUrl2 = res.data;
      this.editForm.actorBgPic = res.data;
    },
    beforeAvatarUpload2(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传头像图片只能是 JPG 格式!");
      }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    },
    enterDown(){
      var g = this
      if(g.isEditForm){
        g.submitForm('editForm',g.currentResCode)
      }else if(g.isShowEditForm2){
        g.isShowEditForm2 = false
      }else if(g.isShowAuditForm){
        g.submitFormForReject('auditForm',currentResCode)
      }else if(!g.loading){
        g.onQuery()
      }
    }
  },

  computed: {
    dDataSpan: function() {
      return 24 - this.labelSpan;
    }
  },
  mounted: function mounted() {
    this.findGender();
    this.findEnables();
    this.findApprovalStatus();
    this.findSendState();
    // this.findSendState();
    this.formQueryCondition.approvalStatus.val = "PendingReview";
    this.onQuery();
    window.setTimeout(this.initTable, 100);
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.main {
  height: 100%;
  width: 100%;
  font-size: 14px;
  color: #333333;
  font-family: "Microsoft YaHei";
}
.datarow {
  border: 1px solid #eeeeee;
  padding: 0px 0px 0px 0px;
  margin-bottom: 0px;
  &:last-child {
    margin-bottom: 0;
  }
}

.titlecol {
  font-weight: bold;
}

.labcol {
  padding: 3px 3px 3px 5px;
  border-radius: 4px;
  font-size: 14px;
  text-align: right;
  border-right: 1px solid #eeeeee;
}

.datacol {
  padding: 3px 3px 3px 3px;
  border-radius: 0px;
  text-align: left;

  vertical-align: middle;
  border-right: 1px solid #eeeeee;
}

.bgrow {
  background-color: #d4f1ff;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>

